<?php

namespace backend\modules\order\controllers;

use backend\extensions\ApiBaseController;
use backend\services\recharge\RechargeOrderService;

class RechargeController extends ApiBaseController
{
    
    /**
     * 列表
     * * */
    public function actionList()
    {
        $params = \Yii::$app->request->get();
        $rules = [
            [['name','phone','state'], 'default', 'value' => 0, 'message' => '名称检索'],
            [['page'], 'default', 'value' => 1, 'message' => '页数'],
            [['page_size'], 'default', 'value' => 10000, 'message' => '每页显示总数'],
        ];
        $validate = $this->validateParams($params, $rules);
        if ($validate) {
            return $this->jsonError($validate);
        }
        $data = RechargeOrderService::getList($this->params);
        return $this->jsonSuccess($data);
    }

    /**
     * 详情
     * * */
    public function actionDetail()
    {
        $params = \Yii::$app->request->post();
        $rules = [
            [['id'], 'required', 'message' => '{attribute}属必填项'],
        ];
        $validate = $this->validateParams($params, $rules);
        if ($validate) {
            return $this->jsonError($validate);
        }
        return RechargeOrderService::detail($this->params);
    }
    
    /**
     * 退款审核
     * * */
    public function actionReview()
    {
        $params = \Yii::$app->request->post();
        $rules = [
            [['order_sn','type'], 'required', 'message' => '{attribute}属必填项'],
        ];
        $validate = $this->validateParams($params, $rules);
        if ($validate) {
            return $this->jsonError($validate);
        }
        return RechargeOrderService::review($this->params);
    }
}
